package com.aaa.member.util;

import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * @fileName:WritePoi
 * @description:
 * @author:李铎
 * @createTime:2020/11/19 16:58
 * @version:1.0.0
 */

public class WritePoi {
    public static void main(String[] args) throws IOException {
        //创建工作簿
        XSSFWorkbook workbook = new XSSFWorkbook();
        //创建工作表
        XSSFSheet sheet = workbook.createSheet("测试表一");
        //创建行
        XSSFRow row = sheet.createRow(0);
        XSSFRow row2 = sheet.createRow(1);
        //创建单元格
        row.createCell(0).setCellValue("李铎");
        row.createCell(1).setCellValue("李铎");
        row.createCell(2).setCellValue("李铎");
        row2.createCell(0).setCellValue("李铎");
        row2.createCell(1).setCellValue("李铎");
        row2.createCell(2).setCellValue("李铎");
        //输出流
        FileOutputStream out = new FileOutputStream("D:\\Poi测试\\工作簿1.xlsx");
        workbook.write(out);
        out.flush();
        //释放资源
        out.close();
        workbook.close();
        System.out.println("写入成功");

    }
}
